<?php /* Smarty version 2.6.20, created on 2016-07-19 15:20:01
         compiled from logistics.htm */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('function', 'html_options', 'logistics.htm', 65, false),array('modifier', 'strip_tags', 'logistics.htm', 273, false),array('modifier', 'truncate', 'logistics.htm', 273, false),)), $this); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>配送管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../script/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../script/jquery.ui.js"></script>
<script type="text/javascript" src="../script/dialog/dialog.js" id="dialog_js"></script>
</head>
<body>
<div class="container">
    <div class="flow">
        <div class="itemtitle">
            <h3>配送管理</h3>
            <ul>
                <li <?php if ($_GET['operation'] == ''): ?>class="current"<?php endif; ?>><a href="?m=<?php echo $_GET['m']; ?>
&s=<?php echo $_GET['s']; ?>
"><span>管理</span></a></li>
                <li <?php if ($_GET['operation'] == 'add'): ?>class="current"<?php endif; ?>><a href="?m=<?php echo $_GET['m']; ?>
&s=<?php echo $_GET['s']; ?>
&operation=add"><span>添加</span></a></li>
				<?php if ($_GET['operation'] == 'edit'): ?>
                <li class="current"><a href="#"><span>修改</span></a></li>
                <?php endif; ?>
                <?php if ($_GET['operation'] == 'set'): ?>
                <li class="current"><a href="#"><span>指定配送地区和费用</span></a></li>
                <?php endif; ?>
            </ul>
		</div>
    </div>
    <div class="h35"></div>
    <script type="text/javascript">
    $(function(){
        /* 全选 */
         $('.checkall').click(function(){
            var _self = this;
            $('.checkitem').each(function(){
                if (!this.disabled)
                {
                    $(this).attr('checked', _self.checked);
                }
            });
            $('.checkall').attr('checked', this.checked);
        });	 
    });
    </script>
	<?php if ($_GET['operation'] == 'add' || $_GET['operation'] == 'edit'): ?>
    <form name="form" id="form" method="post">
        <input name="id" type="hidden" id="id" value="<?php echo $this->_tpl_vars['de']['id']; ?>
">
        <table class="table">
            <thead>
                <tr>
                    <th class="partition" colspan="99">配送管理</th>
                </tr>
            </thead>
            <tbody>
            <tr>
                <td width="100">配送方式名称</td>
                <td>
				<input name="title" type="text" id="title" class="w350" value="<?php echo $this->_tpl_vars['de']['title']; ?>
"/>
                <div id="form-error" class="form-error"></div>
                </td>
            </tr>
            <tr>
                <td width="100">快递单模板</td>
                <td>
				<select name="expresstpl">
	<?php echo smarty_function_html_options(array('options' => $this->_tpl_vars['de']['fast_mail'],'selected' => $this->_tpl_vars['de']['expresstpl']), $this);?>

</select>
                <div id="form-error" class="form-error"></div>
                </td>
            </tr>
            <tr>
                <td>类型</td>
                <td>
				<input type="radio" <?php if ($this->_tpl_vars['de']['type'] == 0): ?>checked="checked"<?php endif; ?> value="0" name="type" id="t1" /><label for="t1">先收款后发货</label>
				<input type="radio" <?php if ($this->_tpl_vars['de']['type'] == 1): ?>checked="checked"<?php endif; ?> value="1" name="type" id="t2" /><label for="t2">货到付款</label>
                </td>
            </tr>
            <tr>
                <td>行邮税</td>
                <td>
				<input type="radio" <?php if ($this->_tpl_vars['de']['is_tax'] == 0): ?>checked="checked"<?php endif; ?> value="0" name="is_tax" id="tax0" /><label for="tax0">不收</label>
				<input type="radio" <?php if ($this->_tpl_vars['de']['is_tax'] == 1): ?>checked="checked"<?php endif; ?> value="1" name="is_tax" id="tax1" /><label for="tax1">实收</label>
				<input type="radio" <?php if ($this->_tpl_vars['de']['is_tax'] == 2): ?>checked="checked"<?php endif; ?> value="2" name="is_tax" id="tax2" /><label for="tax2">保险</label>
                </td>
            </tr>
            <tr>
                <td>可发仓</td>
                <td>
                <?php $_from = $this->_tpl_vars['de']['allstocks']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['list']):
?>
				<input type="checkbox" <?php if ($this->_tpl_vars['list']['selected']): ?>checked="checked"<?php endif; ?> value="<?php echo $this->_tpl_vars['key']; ?>
" name="stocks[]" id="stocks<?php echo $this->_tpl_vars['key']; ?>
" /><label for="stocks<?php echo $this->_tpl_vars['key']; ?>
"><?php echo $this->_tpl_vars['list']['title']; ?>
</label>
				<?php endforeach; endif; unset($_from); ?>
                </td>
            </tr>
            <tr>
                <td width="100">重量设置</td>
                <td>
				 首重重量 <input name="default_num" id="default_num" type="text" value="<?php if ($this->_tpl_vars['de']['default_num']): ?><?php echo $this->_tpl_vars['de']['default_num']; ?>
<?php else: ?>1<?php endif; ?>" class="w50" /> 千克
                 费用 <input name="default_price" id="default_price" type="text" value="<?php if ($this->_tpl_vars['de']['default_price']): ?><?php echo $this->_tpl_vars['de']['default_price']; ?>
<?php else: ?>10<?php endif; ?>" class="w50" /> 元 
                 续重重量 <input name="add_num" id="add_num" type="text" value="<?php if ($this->_tpl_vars['de']['add_num']): ?><?php echo $this->_tpl_vars['de']['add_num']; ?>
<?php else: ?>1<?php endif; ?>" class="w50" /> 千克 
                 费用 <input name="add_price" id="add_price" type="text" value="<?php if ($this->_tpl_vars['de']['add_price']): ?><?php echo $this->_tpl_vars['de']['add_price']; ?>
<?php else: ?>10<?php endif; ?>" class="w50" /> 元
                 满 <input name="free" id="free" type="text" value="<?php if ($this->_tpl_vars['de']['free']): ?><?php echo $this->_tpl_vars['de']['free']; ?>
<?php else: ?>0<?php endif; ?>" class="w50" /> 元免运费（如果填写0则为不免运费） 
                </td>
            </tr>
            <tr>
                <td width="100">详细介绍</td>
                <td>
				<script charset="utf-8" src="../lib/kindeditor/kindeditor-min.js"></script>
				<script>
                var editor;
                KindEditor.ready(function(K) {
                    editor = K.create('textarea[name="content"]', {
                        resizeType : 1,
                        allowPreviewEmoticons : false,
                        allowImageUpload : false
                    });
                });
                </script>
                <textarea style="width:80%; height:300px" name="content"><?php echo $this->_tpl_vars['de']['desc']; ?>
</textarea>
                </td>
            </tr>
            <tr>
            	<td width="100">备注</td>
            	<td>
            		<textarea rows="6" cols="80" name="remark"><?php echo $this->_tpl_vars['de']['remark']; ?>
</textarea>
            	</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>
                <input class="submit" type="submit" value="提交">
                <input name="act" type="hidden" id="action" value="<?php if (! $_GET['editid']): ?>save<?php else: ?>edit<?php endif; ?>">
               
                </td>
            </tr>
            </tbody>
        </table>
        </form>
	<?php elseif ($_GET['operation'] == 'set'): ?>
    <form action="" method="post" id="form" name="form">
	<input name="id" type="hidden" id="id" value="<?php echo $_GET['editid']; ?>
">
    <table class="table ac" width="100%">
        <tr class="partition">
            <th width="1"></th>
            <th class="al">运送到</th>
            <th width="100">起始(kg)</th>
            <th width="100">起始费(元)</th>
            <th width="100">续重重量(kg)</th>
            <th width="100">续重费用(元)</th>
            <th width="100">免运费(元)</th>
        </tr>
        <?php $_from = $this->_tpl_vars['de']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['list']):
?>
        <tr>
            <td></td>
            <td class="al">
                <input name="edit_city[<?php echo $this->_tpl_vars['list']['id']; ?>
]" value="<?php echo $this->_tpl_vars['list']['define_citys']; ?>
" type="hidden"/>
                <?php if ($this->_tpl_vars['list']['define_citys'] == 'default'): ?>
                <span>全国&nbsp;</span>
                <?php else: ?>
                <span><?php echo $this->_tpl_vars['list']['define_citys_txt']; ?>
&nbsp;</span><a data_type="edit" href="javascript:void(0);">编辑</a>&nbsp;<a onclick="return confirm('确定删除吗');"  href="module.php?m=logistics&s=logistics.php&operation=set&editid=<?php echo $_GET['editid']; ?>
&del=<?php echo $this->_tpl_vars['list']['id']; ?>
">删除</a>
                <?php endif; ?>
            </td>
            <td><input type="text" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d.]/g,'')" class="w50" name="edit_default_num[<?php echo $this->_tpl_vars['list']['id']; ?>
]" value="<?php echo $this->_tpl_vars['list']['default_num']; ?>
" /></td>
            <td><input type="text" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d.]/g,'')" class="w50" name="edit_default_price[<?php echo $this->_tpl_vars['list']['id']; ?>
]" value="<?php echo $this->_tpl_vars['list']['default_price']; ?>
" /></td>
            <td><input type="text" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d.]/g,'')" class="w50" name="edit_add_num[<?php echo $this->_tpl_vars['list']['id']; ?>
]" value="<?php echo $this->_tpl_vars['list']['add_num']; ?>
"/></td>
            <td><input type="text" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d.]/g,'')" class="w50" name="edit_add_price[<?php echo $this->_tpl_vars['list']['id']; ?>
]" value="<?php echo $this->_tpl_vars['list']['add_price']; ?>
" /></td>
            <td><input type="text" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" onkeyup="value=value.replace(/[^\d.]/g,'')" class="w50" name="edit_free[<?php echo $this->_tpl_vars['list']['id']; ?>
]" value="<?php echo $this->_tpl_vars['list']['free']; ?>
" /></td>
        </tr>
        <?php endforeach; endif; unset($_from); ?>
        <tr>
            <td class="al" colspan="99"><div><a class="addtr" onclick="addrow(this, 0)" href="javascript:void(0);">添加一级分类</a></div></td>
        </tr>
        <tr>
            <td class="al" colspan="99">
            <input class="submit" type="submit" value="提交">
            <input name="act" type="hidden" id="action" value="<?php if (! $_GET['editid']): ?>save<?php else: ?>edit<?php endif; ?>">
            </td>
        </tr>
    </table>
    </form>
    <script>
	var rowtypedata = [ 
	[
		[1,''],
		[1,'<input name="add_city[]" value="" type="hidden"/><span></span><a data_type="edit" href="javascript:void(0);">编辑</a>&nbsp;<a href="javascript:;" onClick="deleterow(this)">删除</a>','al'], 
		[1,'<input type="text" class="w50" name="default_num[]" value="1" />'], 
		[1,'<input type="text" class="w50" name="default_price[]" value="10" />'], 
		[1,'<input type="text" class="w50" name="add_num[]" value="1" />'], 
		[1,'<input type="text" class="w50" name="add_price[]" value="10" />'], 
		[1,'<input type="text" class="w50" name="free[]" value="0" />']
	],
	];
	var addrowdirect = 0;
	var addrowkey = 0;
	function addrow(obj, type) {
		var table = obj.parentNode.parentNode.parentNode.parentNode.parentNode;
		var tbody = obj.parentNode.parentNode.parentNode.parentNode;
		if(!addrowdirect) {
			var row = table.insertRow(obj.parentNode.parentNode.parentNode.rowIndex);
		} else {
			var row = table.insertRow(obj.parentNode.parentNode.parentNode.rowIndex + 1);
		}
		var typedata = rowtypedata[type];
		for(var i = 0; i <= typedata.length - 1; i++) {
			var cell = row.insertCell(i);
			cell.colSpan = typedata[i][0];
			var tmp = typedata[i][1];
			if(typedata[i][2]) {
				cell.className = typedata[i][2];
			}
			tmp = tmp.replace(/\{(n)\}/g, function($1) {return addrowkey;});
			tmp = tmp.replace(/\{(\d+)\}/g, function($1, $2) {return addrow.arguments[parseInt($2) + 1];});
			cell.innerHTML = tmp;
		}
		addrowkey ++;
		addrowdirect = 0;
	}
	function deleterow(obj) {
		var table = obj.parentNode.parentNode.parentNode.parentNode;
		var tr = obj.parentNode.parentNode;
		table.deleteRow(tr.rowIndex);
	}
	var input=span='';
	$('a[data_type="edit"]').live('click',function(){
		ajax_form("district", '选择城市', '<?php echo $this->_tpl_vars['config']['weburl']; ?>
/admin/module.php?m=logistics&s=district.php', 550,1);
		input=$(this).prevAll("input");
		span=$(this).prevAll("span");
		sca=new Array();
		sct=new Array();
	});
    </script>
    <?php else: ?>
    <form action="" method="post" id="form" name="form">
    <input type="hidden" name="act" value="op" />
    <table class="table">
        <thead>
        <tr>
            <th colspan="99" class="partition">
            <ul class="button">
                <li class="button">
                    <a class="a_button" id="open" href="javascript:void();">开启</a>
                </li>
                
                <li class="button">
                    <a class="a_button" id="close" href="javascript:void();">禁用</a>
                </li>
                
                <li class="button">
                    <a class="a_button" id="delete" href="javascript:void();">删除</a>
                </li>
            </ul>
            </th>
        </tr>
        </thead>
        <tbody>
            <tr class="header">
                <th width="10" class="pl20"><input type="checkbox" class="checkall"></th>
                <th width="55" class="ac">操作</th>
                <th width="100">配送方式名称</th>
                <th>配送方式描述</th>
                <th width="150">备注</th>
                <th class="ac" width="60">货到付款</th>
                <th class="ac" width="60">行邮税</th>
                <th class="ac" width="320">可发仓</th>
                <th class="ac" width="60">是否开启</th>
            </tr>
            <?php $_from = $this->_tpl_vars['de']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['list']):
?>
            <tr>
                <td class="pl20"><input type="checkbox" value="<?php echo $this->_tpl_vars['list']['id']; ?>
" class="checkitem" name="chk[]"></td>
                <td class="ac">
                <a href="module.php?m=logistics&s=logistics.php&operation=edit&editid=<?php echo $this->_tpl_vars['list']['id']; ?>
"><?php echo $this->_tpl_vars['editimg']; ?>
</a>
                <a href="module.php?m=logistics&s=logistics.php&operation=set&editid=<?php echo $this->_tpl_vars['list']['id']; ?>
"><?php echo $this->_tpl_vars['setimg']; ?>
</a>
                </td>
                <td><?php echo $this->_tpl_vars['list']['title']; ?>
</td>
                <td><?php echo ((is_array($_tmp=((is_array($_tmp=$this->_tpl_vars['list']['desc'])) ? $this->_run_mod_handler('strip_tags', true, $_tmp) : smarty_modifier_strip_tags($_tmp)))) ? $this->_run_mod_handler('truncate', true, $_tmp, 60) : smarty_modifier_truncate($_tmp, 60)); ?>
</td>
                <td><?php echo $this->_tpl_vars['list']['remark']; ?>
</td>       
                <td class="ac"><?php if ($this->_tpl_vars['list']['type'] == 1): ?>是<?php else: ?>否<?php endif; ?></td>
                <td class="ac"><?php if ($this->_tpl_vars['list']['is_tax'] == 1): ?>实收<?php elseif ($this->_tpl_vars['list']['is_tax'] == 2): ?>保险<?php else: ?>不收<?php endif; ?></td>
                <td class="ac"><?php echo $this->_tpl_vars['list']['stocks']; ?>
</td>
                <td class="ac"><?php if ($this->_tpl_vars['list']['status'] == 1): ?>开启<?php else: ?>禁用<?php endif; ?></td>
                
            </tr>
            <?php endforeach; else: ?>
            <tr>
                <td class="norecord" colspan="99"><i></i><span>暂无符合条件的数据记录</span></td>
            </tr>
            <?php endif; unset($_from); ?>
        </tbody>
    </table>
    </form>
    <?php endif; ?>
</div>
<script>
    $(".a_button").click(function () {
        var obj=$("input[type='checkbox']:checked");
        if(!obj.length)
        {
            alert('对不起，请选择数据，再进行操作!');
            return false;
        }
        $('input[name="act"]').val((this.id));
        $("#form")[0].submit();
        return false;
    });
    </script>  
</body>
</html>